import {
  SCREEN_WIDTH,
  SCREEN_HEIGHT,
  IS_TABLET_DEVICE,
  TABLET_WIDTH
} from '../constant';

export interface Screen {
  width: number;
  height: number;
}

export enum ScreenOrientation {
  Portrait,
  Landscape
}

export const getScreenInfo = ({
  screenOrientation = ScreenOrientation.Portrait
}: {
  screenOrientation?: ScreenOrientation;
}): Screen => {
  if (screenOrientation === ScreenOrientation.Portrait) {
    const screenWidth = IS_TABLET_DEVICE
      ? TABLET_WIDTH
      : Math.min(SCREEN_WIDTH, SCREEN_HEIGHT);
    const screenHeight = Math.max(SCREEN_WIDTH, SCREEN_HEIGHT);
    const width = screenWidth > screenHeight ? screenHeight : screenWidth;
    const height = screenWidth > screenHeight ? screenWidth : screenHeight;
    return {
      width,
      height
    };
  }
  const width = SCREEN_WIDTH > SCREEN_HEIGHT ? SCREEN_WIDTH : SCREEN_HEIGHT;
  const height = SCREEN_WIDTH > SCREEN_HEIGHT ? SCREEN_HEIGHT : SCREEN_WIDTH;
  return {
    width,
    height
  };
};
